<template>
  <view class="container">
    <view class="content">
      <view class="header">
        <text class="title">睡眠分析</text>
      </view>
      
      <view class="analysis-card">
        <view class="card-header">
          <text class="card-title">本周睡眠概况</text>
        </view>
        <view class="stats-grid">
          <view class="stat-item">
            <text class="stat-value">7.2</text>
            <text class="stat-label">平均睡眠时长(小时)</text>
          </view>
          <view class="stat-item">
            <text class="stat-value">85%</text>
            <text class="stat-label">睡眠质量评分</text>
          </view>
          <view class="stat-item">
            <text class="stat-value">23:30</text>
            <text class="stat-label">平均入睡时间</text>
          </view>
          <view class="stat-item">
            <text class="stat-value">6</text>
            <text class="stat-label">连续记录天数</text>
          </view>
        </view>
      </view>
      
      <view class="chart-section">
        <text class="section-title">睡眠趋势</text>
        <view class="chart-placeholder">
          <text class="chart-text">睡眠时长趋势图表</text>
        </view>
      </view>
      
      <view class="tips-section">
        <text class="section-title">改善建议</text>
        <view class="tip-list">
          <view class="tip-item">
            <text class="tip-icon">💡</text>
            <text class="tip-text">建议保持规律的作息时间，每天同一时间入睡</text>
          </view>
          <view class="tip-item">
            <text class="tip-icon">🌙</text>
            <text class="tip-text">睡前避免使用电子设备，营造良好的睡眠环境</text>
          </view>
          <view class="tip-item">
            <text class="tip-icon">🏃</text>
            <text class="tip-text">适量运动有助于改善睡眠质量</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'AnalysisPage',
  data() {
    return {
      sleepData: []
    };
  },
  onLoad() {
    this.getSleepData();
  },
  methods: {
    getSleepData() {
      // 模拟获取睡眠数据
      this.sleepData = [
        { date: '2024-01-01', duration: 7.5, quality: 85 },
        { date: '2024-01-02', duration: 6.8, quality: 80 },
        { date: '2024-01-03', duration: 7.2, quality: 88 }
      ];
    }
  }
};
</script>

<style>
.container {
  min-height: 100vh;
  background-color: #f5f5f5;
}

.content {
  padding: 20rpx;
}

.header {
  padding: 30rpx 0;
  text-align: center;
}

.title {
  font-size: 36rpx;
  font-weight: bold;
  color: #333;
}

.analysis-card {
  background-color: #fff;
  border-radius: 16rpx;
  padding: 30rpx;
  margin-bottom: 30rpx;
  box-shadow: 0 2rpx 20rpx rgba(0, 0, 0, 0.08);
}

.card-header {
  margin-bottom: 30rpx;
}

.card-title {
  font-size: 32rpx;
  font-weight: bold;
  color: #333;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30rpx;
}

.stat-item {
  text-align: center;
  padding: 20rpx;
  background-color: #f8f9fa;
  border-radius: 12rpx;
}

.stat-value {
  display: block;
  font-size: 40rpx;
  font-weight: bold;
  color: #2979ff;
  margin-bottom: 8rpx;
}

.stat-label {
  font-size: 24rpx;
  color: #666;
}

.chart-section {
  background-color: #fff;
  border-radius: 16rpx;
  padding: 30rpx;
  margin-bottom: 30rpx;
  box-shadow: 0 2rpx 20rpx rgba(0, 0, 0, 0.08);
}

.section-title {
  font-size: 32rpx;
  font-weight: bold;
  color: #333;
  margin-bottom: 20rpx;
  display: block;
}

.chart-placeholder {
  height: 300rpx;
  background-color: #f8f9fa;
  border-radius: 12rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-text {
  font-size: 28rpx;
  color: #999;
}

.tips-section {
  background-color: #fff;
  border-radius: 16rpx;
  padding: 30rpx;
  box-shadow: 0 2rpx 20rpx rgba(0, 0, 0, 0.08);
}

.tip-list {
  margin-top: 20rpx;
}

.tip-item {
  display: flex;
  align-items: flex-start;
  margin-bottom: 20rpx;
}

.tip-item:last-child {
  margin-bottom: 0;
}

.tip-icon {
  font-size: 32rpx;
  margin-right: 16rpx;
  margin-top: 4rpx;
}

.tip-text {
  flex: 1;
  font-size: 28rpx;
  color: #666;
  line-height: 1.5;
}
</style> 